<% layout('/layouts/default.html', {title: '参与活动管理', libs: ['dataGrid']}){ %>
<div class="main-content">
	<div class="box box-main">
		<div class="box-header">
			<div class="box-title">
				<i class="fa icon-notebook"></i> ${text('参与活动管理')}
			</div>
			<div class="box-tools pull-right">
				<a href="#" class="btn btn-default" id="btnSearch" title="${text('查询')}"><i class="fa fa-filter"></i> ${text('查询')}</a>
				<% if(hasPermi('kj:kjMemberJob:edit')){ %>
<!--					<a href="${ctx}/kj/kjMemberJob/form" class="btn btn-default btnTool" title="${text('新增参与活动')}"><i class="fa fa-plus"></i> ${text('新增')}</a>-->
				<% } %>
				<a href="#" class="btn btn-default" id="btnSetting" title="${text('设置')}"><i class="fa fa-navicon"></i></a>
				<div class="btn-group">
					<a href="javascript:" class="btn btn-default dropdown-toggle" data-toggle="dropdown">
						<i class="fa fa-navicon"></i> <span class="caret"></span>
					</a>
					<ul class="dropdown-menu">
						<li><a href="javascript:" id="btnExport"><i class="glyphicon glyphicon-export"></i> ${text('导出')}</a></li>
					</ul>
				</div>
			</div>
		</div>
		<div class="box-body">
			<#form:form id="searchForm" model="${kjMemberJob}" action="${ctx}/kj/kjMemberJob/listData" method="post" class="form-inline hide"
					data-page-no="${parameter.pageNo}" data-page-size="${parameter.pageSize}" data-order-by="${parameter.orderBy}">
			<div class="form-group">
				<label class="control-label">${text('用户名')}：</label>
				<div class="control-inline">
					<#form:input id="kjMember.name" title="用户名" path="kjMember.name" />
				</div>
			</div>
			<div class="form-group">
				<label class="control-label">${text('地区')}：</label>
				<div class="control-inline">
					<#form:listselect id="citySelect" title="地区选择"
					path="cityId"  labelPath="cityName"
					url="${ctx}/kj/kjCity/kjCitySelect?pageSize=1000" allowClear="false" callbackFuncName='cityselectCallback'
					checkbox="false" itemCode="id" itemName="name"/>
				</div>
			</div>
			<div class="form-group">
				<label class="control-label">${text('活动')}：</label>
				<div class="control-inline">
					<#form:listselect id="activitySelect" title="活动选择"
					path="activityId"  labelPath="activityName"
					url="${ctx}/kj/kjActivity/kjActivitySelect" allowClear="false"
					checkbox="false" itemCode="id" itemName="name"/>
				</div>
			</div>
				<div class="form-group">
					<label class="control-label">${text('审批状态')}：</label>
					<div class="control-inline width-120">
						<#form:select path="approveStatus" dictType="approve_status" blankOption="true" class="form-control"/>
					</div>
				</div>

				<div class="form-group">
					<button type="submit" class="btn btn-primary btn-sm">${text('查询')}</button>
					<button type="reset" class="btn btn-default btn-sm">${text('重置')}</button>
				</div>
			</#form:form>
			<table id="dataGrid"></table>
			<div id="dataGridPage"></div>
		</div>
	</div>
</div>
<% } %>
<script>
// 初始化DataGrid对象
$('#dataGrid').dataGrid({
	searchForm: $("#searchForm"),
	columnModel: [

		{header:'${text("用户名")}', name:'kjMember.name', index:'m.name', width:150, align:"left"
			, frozen:true, formatter: function(val, obj, row, act){
				return '<a href="${ctx}/kj/kjMemberJob/form?id='+row.id+'" class="btnList" data-title="${text("编辑活动报名")}">'+(val||row.id)+'</a>';
			}},
		{header:'${text("中兴工号")}', name:'kjMember.memberNo', index:'m.member_no', width:150, align:"left"},
		{header:'${text("活动名")}', name:'activityName', index:'a.activity_name', width:150, align:"left"},
		{header:'${text("电话")}', name:'kjMember.mobile', index:'m.mobile', width:150, align:"left"},
		{header:'${text("地区")}', name:'cityName', index:'a.cityName', width:150, align:"left"},
		{header:'${text("岗位名")}', name:'jobName', index:'a.job_name', width:150, align:"left"},
		{header:'${text("审批状态")}', name:'approveStatus', index:'a.approve_status', width:150, align:"left", formatter: function(val, obj, row, act){
				return js.getDictLabel(${@DictUtils.getDictListJson('approve_status')}, val, '未知', true);
			}},

		{header:'${text("驳回理由")}', name:'remarks', index:'a.remarks', width:150, align:"left"},
		{header:'${text("操作")}', name:'actions', width:120, sortable:false, title:false, formatter: function(val, obj, row, act){
			var actions = [];
			<% if(hasPermi('kj:kjMemberJob:edit')){ %>
			if(row.approveStatus == '0' || row.kjActivity.activityStatus < 2){
				actions.push('<a href="${ctx}/kj/kjMemberJob/form?id='+row.id+'" class="btnList" title="${text("编辑参与活动")}"><i class="fa fa-pencil"></i></a>&nbsp;');
			}
				// actions.push('<a href="${ctx}/kj/kjMemberJob/delete?id='+row.id+'" class="btnList" title="${text("删除参与活动")}" data-confirm="${text("确认要删除该参与活动吗？")}"><i class="fa fa-trash-o"></i></a>&nbsp;');
			<% } %>
			return actions.join('');
		}}
	],
	// 加载成功后执行事件
	ajaxSuccess: function(data){

	}
});
function cityselectCallback(id, act, index, layero, selectData){
	//console.log(id, act, index, layero, selectData[0])
	if (act == 'ok' || act == 'clear'){
		var win = layero.iframeWindow();
		log(win);    // 选择框内容的window对象
		log(act);    // 回调活动事件（ok、clear、cancel）
		log(index);  // layer的index
		log(layero); // layer实例对象
		log(selectData);  // 选择的节点数据
		if(selectData[Object.keys(selectData)[0]]!==undefined){
			$('#activitySelectDiv').attr('data-url', '/kj/a/kj/kjActivity/kjActivitySelect?kjCity.id=' + selectData[Object.keys(selectData)[0]].id);
		}else {
			$('#activitySelectDiv').attr('data-url', '/kj/a/kj/kjActivity/kjActivitySelect');
		}
	}
}
$('#btnExport').click(function(){
	js.ajaxSubmitForm($('#searchForm'), {
		url: '${ctx}/kj/kjMemberJob/exportData',
		downloadFile: true
	});
});
</script>
